<include file="Public:header" />
<div class="page-member subpage">
    <div class="form-header">
        <div>
            <div class="line1">
                <div class="fl"><h3>合同信息 / 新增</h3></div>
                <div class="fr hidden">
                    <form class="search-form" method="post" action="">
                        <input name="field" value="{$filter.field}" type="text" />
                        <input name="value" value="{$filter.value}" type="text" />
                        <input name="page" value="{$filter.page}" type="hidden" />
                        <input name="order_field" value="{$filter.order_field}" type="hidden" />
                        <input name="order_sort" value="{$filter.order_sort}" type="hidden" />
                        <button class="btn-normal" type="submit">查 询</button>
                    </form>
                </div>
            </div>
            <div class="line2">
                <div class="fl form-btn-group">
                    <in name="$x|default='02-01-02'" value="$rightsCode">
                        <button onclick="submitForm();" class="btn-save btn-highlight">保 存</button>
                        <else />
                        <button disabled="disabled" class="btn-save btn-disable">保 存</button>
                    </in>
                    <span>或</span>
                    <a class="linkBtn btn-abort" href="/admin/contact/index">放弃</a>
                </div>
            </div>
        </div>
    </div>
    <div class="form-box2">
        <div>
            <form id="contactForm" method="post" action="">
                <input type="hidden" name="id" id="id" value="{$contact.id}" />
                <table class="form">
                    <tr>
                        <th width="15%">业务编号<span class="hint">*</span></th>
                        <td width="35%"><input name="ywno" type="text" value="{$contact.ywno}" /> </td>
                        <th width="15%">合同类型<span class="hint">*</span></th>
                        <td><input class="disabled" name="type" type="text" value="{$contact.type}" /></td>
                    </tr>
                    <tr>
                        <th>房屋地址<span class="hint">*</span></th>
                        <td>
                            <input class="hidden" name="community" type="text" value="{$contact.community}" />
                            <input class="hidden" name="fwbh" type="text" value="{$contact.fwbh}" />
                            <input class="disabled" name="fwdz" type="text" value="{$contact.fwdz}" />
                        </td>
                        <th>房屋面积<span class="hint">*</span></th>
                        <td><input class="disabled" name="size" type="text" value="{$contact.size}" /> </td>
                    </tr>
                    <tr>
                        <th>标准月租金(元)<span class="hint">*</span></th>
                        <td><input class="disabled" name="zj" type="text" value="{$contact.zj}" /> </td>
                        <th>市场月租金(元)<span class="hint">*</span></th>
                        <td><input class="disabled" name="mzj" type="text" value="{$contact.mzj}" /> </td>
                    </tr>
                    <tr>
                        <th>甲方<span class="hint">*</span></th>
                        <td><input class="disabled" name="jiafang" type="text" value="{$contact.jiafang|default=C('CONTACT_JIAFANG')}" /> </td>
                        <th>乙方<span class="hint">*</span></th>
                        <td><input class="disabled" name="yifang" type="text" value="{$contact.yifang}" /> </td>
                    </tr>
                    <tr>
                        <th>合同开始日期<span class="hint">*</span></th>
                        <td><input class="disabled" name="ksrq" type="text" value="{$contact.ksrq|default=$contactDate['start']}" /> </td>
                        <th>合同结束日期<span class="hint">*</span></th>
                        <td><input class="disabled" name="jsrq" type="text" value="{$contact.jsrq|default=$contactDate['end']}" /> </td>
                    </tr>
                    <tr>
                        <th>押金(元)<span class="hint">*</span></th>
                        <td><input name="yj" type="text" value="{$contact.yj}" /> </td>
                        <th>低保人口<span class="hint">*</span></th>
                        <td><input class="disabled" name="dibaork" type="text" value="{$contact.dibaork|default=0}" /> </td>
                    </tr>
                    <tr>
                        <th>减免类型<span class="hint">*</span></th>
                        <td>
                            <select name="derate_type" style="width: 215px;">
                                <volist name="derate_type" id="vo" key="index">
                                    <option value="{$vo[0]}" derate="{$vo[1]}">{$vo[0]}</option>
                                </volist>
                            </select>
                        </td>
                        <th>减免金额(元)<span class="hint">*</span></th>
                        <td><input class="disabled" name="derate_money" type="text" value="{$contact.derate_money|default='0.00'}" /> </td>
                    </tr>
                    <tr>
                        <th>应缴租金<span class="hint">*</span></th>
                        <td><input class="disabled" name="total2" type="text" value="{$contact.total2}" /> </td>
                        <th>减免后应缴租金<span class="hint">*</span></th>
                        <td><input class="disabled" name="total" type="text" value="{$contact.total}" /> </td>
                    </tr>
                    <tr>
                        <th>甲方法定代表人<span class="hint">*</span></th>
                        <td><input name="jffr" type="text" value="{$contact.jffr|default=C('CONTACT_FAREN')}" /> </td>
                        <th>乙方身份证身份证<span class="hint">*</span></th>
                        <td><input class="disabled" name="yfsfz" type="text" value="{$contact.yfsfz}" /> </td>
                    </tr>
                    <tr>
                        <th>甲方经办人<span class="hint">*</span></th>
                        <td><input name="jfjbr" type="text" value="{$contact.jfjbr|default=C('CONTACT_JINBAN')}" /> </td>
                        <th>乙方联系地址</th>
                        <td><input name="yfdz" type="text" value="{$contact.yfdz}" /> </td>
                    </tr>
                    <tr>
                        <th>甲方联系电话<span class="hint">*</span></th>
                        <td><input name="jfdh" type="text" value="{$contact.jfdh|default=C('CONTACT_PHONE')}" /> </td>
                        <th>乙方电话<span class="hint">*</span></th>
                        <td><input name="yfdh" type="text" value="{$contact.yfdh}" /> </td>
                    </tr>
                    <tr style="vertical-align: top;">
                        <th>签订日期<span class="hint">*</span></th>
                        <td><input name="ctime" type="text" value="{$contact.ctime|default=time()|date='Y/m/d',###}" /> </td>
                        <th>备注</th>
                        <td><textarea placeholder="请输入备注信息" style="width:210px;" name="remarks">{$contact.remarks}</textarea></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<link type="text/css" href="__JS__/autocomplete2/src/jquery.autocomplete.min.css" rel="stylesheet">
<script src="__JS__/autocomplete2/src/jquery.autocomplete.js" type="text/javascript"></script>
<script>
    //disable所有自动填充字段；
    $(".disabled").attr("disabled", true);

    $('input[name=ywno]').autocomplete({
        serviceUrl: '/admin/contact/ajax_SearchYaohaoByNo',
        extraParams: {ywno: $.trim($("input[name=ywno]").val())},//动态参数值
        paramName: "ywno",//自定义的参数名 必须和extraParams 参数名相同
        showNoSuggestionNotice: true,
        noSuggestionNotice: '对不起，没有匹配到待入住的业务编号',
        onSelect: function (suggestion) {
            $("input[name=type]").val(suggestion.data.type);
            $("input[name=community]").val(suggestion.data.community);
            $("input[name=fwbh]").val(suggestion.data.hno);
            $("input[name=size]").val(suggestion.data.size);
            $("input[name=zj]").val(suggestion.data.price);
            $("input[name=mzj]").val(suggestion.data.mprice);
            $("input[name=fwdz]").val(suggestion.data.addr);
            $("input[name=dibaork]").val(suggestion.data.dibaork);
            $("input[name=total]").val(suggestion.data.total.toFixed(2));
            $("input[name=total2]").val(suggestion.data.total.toFixed(2));
            $("input[name=yj]").val(suggestion.data.yajin);
            $("input[name=yifang]").val(suggestion.data.name);
            $("input[name=yfsfz]").val(suggestion.data.idno);
            $("input[name=yfdh]").val(suggestion.data.phone);
        }
    });

    $(document).ready(function(){
        $("select[name=derate_type]").change(function(){
            var total = parseFloat($("input[name=total2]").val());
            var derate = parseFloat($(this).find("option:selected").attr("derate"));
            var derate_money = total * derate;
            $("input[name=total]").val((total-derate_money).toFixed(2));
            $("input[name=derate_money]").val(derate_money.toFixed(2));
        });

        $("input[name=state]").click(function(){
            if($(this).prop("checked")){
                $("input[name=state]").prop("checked", false);
                $(this).prop("checked", true);
            }
        });
    });
</script>
<script src="__JS__/contact.js" type="text/javascript" ></script>
<include file="Public:footer" />
